package com.wl.center.task.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.wl.center.model.task.*;

import com.wl.center.task.mapper.CustomerMapper;

import com.wl.center.task.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author WangLiang
* @description 针对表【customer】的数据库操作Service实现
* @createDate 2023-02-27 21:48:34
*/
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
    implements CustomerService {
    @Autowired
    private CustomerService customerService;
    @Autowired
    private TypeService typeService;
    @Autowired
    private CountryService countryService;
    @Autowired
    private LevelService levelService;
    @Autowired
    private AgentService agentService;
    @Autowired
    private ProjectService projectService;
    @Override
    public Customer getcustomerById(Long id) {
        //Customer customer = new Customer();
        Customer customer1 = customerService.getById(id);
        Integer typeId = customer1.getTypeId();
        Integer agentId = customer1.getAgentId();
        Integer countryId = customer1.getCountryId();
        Integer levelId = customer1.getLevelId();
        Integer projectId = customer1.getProjectId();
        Type type = typeService.getById(typeId);
        if (type.getStatus()==0){
            customer1.setTypeId(null);
        }
        Country country = countryService.getById(countryId);
        if (country.getStatus()==0){
            customer1.setCountryId(null);
        }
        Agent agent = agentService.getById(agentId);
        if (agent.getStatus()==0){
            customer1.setAgentId(null);
        }
        Level level = levelService.getById(levelId);
        if (level.getStatus()==0){
            customer1.setLevelId(null);
        }
        Project project = projectService.getById(projectId);
        if(project.getStatus()==0){
            customer1.setProjectId(null);
        }
        return customer1;
    }
}




